var r10, r100, rsec, wsec, stime;

r10 = document.getElementById("ch0_0")
r100 = document.getElementById("ch0_1")
rsec = document.getElementById("ch1_0")
wsec = document.getElementById("ch1_1")
stime = document.getElementById("stime");

function scaleit(val) {
	var s =document.getElementById("scaler");
	var t = document.getElementById("scaletext");
	var r10 = document.getElementById("ch0_0")
	var r100 = document.getElementById("ch0_1")
	s.value = val;
	t.value = val;
	val = val / 100;
	r100.scale = val; 
	r10.scale = val; 
}


function startData() {
        r10 = document.getElementById("ch0_0")
        r100 = document.getElementById("ch0_1")
        rsec = document.getElementById("ch1_0")
        wsec = document.getElementById("ch1_1")
        stime = document.getElementById("stime");
        var data_conn = new dataListener(null)
//      onTick( );
}



function doData(rsltObj) {
    r10.setData(rsltObj['r10']);   
    r100.setData(rsltObj['r100']);   
    rsec.setData(rsltObj['iostats']['rsec']);   
    wsec.setData(rsltObj['iostats']['wsec']);
    stime.value = rsltObj['date']+" "+rsltObj['time'];
}

var cli_session = null;
var cli_connected = false;
var cli;
var cmd_start;

dataListener.prototype = new webListener();

dataListener.prototype._onLoad =
function ( stat, text, len) {
    dump("TickLOAD "+text+"\n");
    try {
        var rsltObj = JSON.parse(text);
        //alert(len+" "+text.length+" >"+text+"< "+rsltObj['r10'])
        doData(rsltObj);
    } catch(e) {
        alert(text+" "+e);
    }
}

dataListener.prototype._onProgress =
function ( stat, text, len) {
    dump("TickPROGRESS "+text+"\n");
    var rsltObj = JSON.parse(text);
        var dt = rsltObj['date']
        dt = dt+" "+rsltObj['time']
        var tick = document.getElementById("cv_stat_datetime");
    tick.setAttribute("value",dt);
}


var dataURL = "/pc/data.pc"
function dataListener( data, user, pass) {
        this._url = dataURL;
        this._user = user;
        this._pass = pass;
        this.multipart = true;
        this._doit( data);
}

